<!DOCTYPE html>
<html>
  
<head><meta name="generator" content="Hexo 3.9.0">
  <meta charset="utf-8">
  <meta name="author" content="youxiaxiaomage">
  
  
  <title>Linux配置nginx服务+ftp服务 | 游侠小马哥</title>

  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

  
    <meta name="keywords" content="nginx,linux,nginx,ftp,">
  

  
  <meta name="description" content="游侠小马哥">

  

  
    <script src="//cdn.jsdelivr.net/npm/leancloud-storage@3.11.1/dist/av-min.js" async></script>
  

  
    <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML" async></script>
  

  
    <script src="//unpkg.com/valine/dist/Valine.min.js" async></script>
  

  

  <script>
  // theme-ad's config script
  // it can be used in every script
  
  window.AD_CONFIG = {
    leancloud: {"appid":"Hyq9wkH495DgNHWhDQCOfQSp-gzGzoHsz","appkey":"WaR7nrzhliHj9aVwdQzkdlGd","comment":true,"count":"true# 是否开启文章统计"},
    welcome: {"enable":false,"interval":30},
    start_time: "2019-06-15",
    passwords: ["efe07af7441da2b69c4a41e42e73be4db47f66010a56900788a458354a7373ec", ],
    is_post: true,
    lock: false,
    author: "youxiaxiaomage",
    share: {"twitter":false,"facebook":false,"weibo":true,"qq":true,"wechat":true},
    mathjax: true,
    page_type: "",
    root: "/blog/"
  };
</script>

  <script src="/blog/vendor/sha256.min.js"></script>
<script src="/blog/js/auth.js"></script>
<script src="/blog/js/index.js"></script>
<script src="/blog/vendor/qrcode.min.js"></script>

  
    <link rel="icon" href="/blog/images/favicon.ico">
    <link rel="apple-touch-icon" href="/blog/images/touch-icon.png">
  

  <link href="//netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">

  <link rel="stylesheet" href="/blog/css/index.css">
<link rel="stylesheet" href="/blog/styles/components/highlight/highlight.css">

  
</head>
  <body>
    <header class="site-header">
  <div class="site-header-brand">
    
      <span class="site-header-brand-title">
        <a href="/blog/">游侠小马哥</a>
      </span>
    
    
      <span class="site-header-brand-motto"> | 宁静致远</span>
    
  </div>
  <div class="site-header-right">
    <nav class="site-header-navigation">
      
        <a href="/blog/" target="_self">首页</a>
      
        <a href="/blog/archives/" target="_self">归档</a>
      
        <a href="/blog/tags/" target="_self">标签</a>
      
        <a href="/blog/categories/" target="_self">分类</a>
      
        <a href="/blog/friends/" target="_self">友链</a>
      
        <a href="/blog/about/" target="_self">关于</a>
      
    </nav>
    <div class="site-header-btn">
      
        <a href="https://github.com/youxiaxiaomage/" target="_blank" id="site-github">
          <i class="fa fa-github-alt"></i>
        </a>
      
      <a href="javascript:void(0);" id="site-search">
        <i class="fa fa-search"></i>
      </a>
      <a href="javascript:void(0);" id="site-nav-btn">
        <i class="fa fa-ellipsis-v"></i>
      </a>
    </div>
  </div>
</header>
<nav class="table-content" id="site-nav">
  <div class="table-content-title">
    <span>导航</span>
  </div>
  <div class="table-content-main">
    <ol class="toc">
      
        <li class="toc-item">
          <a href="/blog/" target="_self">
            首页
          </a>
        </li>
      
        <li class="toc-item">
          <a href="/blog/archives/" target="_self">
            归档
          </a>
        </li>
      
        <li class="toc-item">
          <a href="/blog/tags/" target="_self">
            标签
          </a>
        </li>
      
        <li class="toc-item">
          <a href="/blog/categories/" target="_self">
            分类
          </a>
        </li>
      
        <li class="toc-item">
          <a href="/blog/friends/" target="_self">
            友链
          </a>
        </li>
      
        <li class="toc-item">
          <a href="/blog/about/" target="_self">
            关于
          </a>
        </li>
      
    </ol>
  </div>
</nav>
<div id="site-process"></div>
    <main>
      
  <div class="passage">
  <div class="passage-meta">
    <span>
      <i class="fa fa-calendar"></i>2019-06-20
    </span>
    
      <span>
        | <a href="/blog/categories/nginx/"><i class="fa fa-bookmark"></i>nginx</a>
      </span>
    
    
      <span>
        | <i class="fa fa-unlock-alt"></i>UNLOCK
      </span>
    
  </div>
  <h1 class="passage-title">
    Linux配置nginx服务+ftp服务
  </h1>
  
  <article class="passage-article">
    <h4 id="1-搭建nginx"><a href="#1-搭建nginx" class="headerlink" title="1.搭建nginx"></a>1.搭建nginx</h4><ol>
<li>安装之前首先确认系统中是否已安装gcc、openssl-devel、pcre-devel、zlib-devel、gcc-c++</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum -y install gcc openssl-devel pcre-devel zlib-devel gcc-c++</span><br></pre></td></tr></table></figure>

<ol start="2">
<li>安装pcre-devel库（使Nginx支持http rewrite的模块）</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">tar zxvf pcre-8.39.tar.gz</span><br><span class="line">cd pcre-8.39</span><br><span class="line">./configure</span><br><span class="line">make</span><br><span class="line">make install</span><br></pre></td></tr></table></figure>

<p>问题：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">libtool: compile: unrecognized option `-DHAVE_CONFIG_H&apos;</span><br><span class="line">libtool: compile: Try `libtool --help&apos; for more information.</span><br><span class="line">make[1]: *** [pcrecpp.lo] Error 1</span><br><span class="line">make[1]: Leaving directory `/home/guangbo/work/pcre-8.39&apos;</span><br><span class="line">make: *** [all] Error 2</span><br></pre></td></tr></table></figure>

<p>缺少gcc-c++和libtool，也就是c++编译包<br>解决方法：需要先安装libtool和gcc-c++</p>
<p>#yum -y install libtool</p>
<p>#yum -y install gcc-c+</p>
<ol start="3">
<li>安装Nginx</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">tar zxvf nginx-1.10.2.tar.gz</span><br><span class="line">cd nginx-1.10.2</span><br><span class="line">./configure --with-http_stub_status_module --with-http_gzip_static_module --prefix=/usr/local/nginx</span><br><span class="line">make</span><br><span class="line">make install</span><br><span class="line">注：--with-http_stub_status_module 可以用来启用Nginx的NginxStatus功能，以监控Nginx的当前状态。</span><br><span class="line">	   --with-http_gzip_static_module 支持在线实时压缩输出数据流。</span><br></pre></td></tr></table></figure>

<p>问题：</p>
<p>若在./configure后配置刚才的参数，提示一下的错误：<br> <figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line">objs/src/http/modules/ngx_http_browser_module.o \</span><br><span class="line">objs/src/http/modules/ngx_http_upstream_ip_hash_module.o \</span><br><span class="line">objs/src/http/modules/ngx_http_upstream_least_conn_module.o \</span><br><span class="line">objs/src/http/modules/ngx_http_upstream_keepalive_module.o \</span><br><span class="line">objs/ngx_modules.o \</span><br><span class="line">-lpthread -lcrypt -lpcre -lcrypto -lcrypto -lz</span><br><span class="line">objs/src/core/ngx_regex.o: In function `ngx_pcre_free_studies&apos;:</span><br><span class="line">/share/nginx-1.10.2src/core/ngx_regex.c:307: undefined reference to `pcre_free_study&apos;</span><br><span class="line">collect2: ld returned 1 exit status</span><br><span class="line">make[1]: *** [objs/nginx] Error 1</span><br><span class="line">make[1]: Leaving directory `/share/nginx-1.10.2&apos;</span><br><span class="line">make: *** [build] Error 2</span><br><span class="line"> </span><br><span class="line">解决方法：</span><br><span class="line">./configure --prefix=/usr/local/nginx --without-http_autoindex_module --without-http_geo_module --without-http_map_module --without-http_browser_module --with-http_stub_status_module --with-http_realip_module --with-pcre=../pcre-8.39</span><br><span class="line"> </span><br><span class="line">PS:   ./configure --prefix=/usr/localnx --without-http_autoindex_module --without-http_geo_module --with-pcre=../pcre-8.39</span><br><span class="line"></span><br><span class="line">注意：把--with-pcre=../pcre-8.39换成你的pcre解压缩包的路径</span><br></pre></td></tr></table></figure></p>
<ol start="4">
<li>启动命令</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf。 </span><br><span class="line">/usr/local/nginx/sbin/nginx是你nginx的安装目录；nginx.conf是配置文件。</span><br><span class="line">启动Nginx出现的问题：</span><br><span class="line">/usr/local/nginx/sbin/nginx</span><br></pre></td></tr></table></figure>

<p>/usr/local/nginx/sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory</p>
<p>从错误看出是缺少lib文件导致，进一步查看下</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"># ldd $(which /usr/local/nginx/sbin/nginx)</span><br><span class="line">linux-gate.so.1 =&gt; (0x0071b000)</span><br><span class="line">libpthread.so.0 =&gt; /lib/libpthread.so.0 (0×00498000)</span><br><span class="line">libcrypt.so.1 =&gt; /lib/libcrypt.so.1 (0×00986000)</span><br><span class="line">libpcre.so.1 =&gt; not found</span><br><span class="line">libcrypto.so.6 =&gt; /lib/libcrypto.so.6 (0×00196000)</span><br><span class="line">libz.so.1 =&gt; /lib/libz.so.1 (0×00610000)</span><br><span class="line">libc.so.6 =&gt; /lib/libc.so.6 (0x002d7000)</span><br><span class="line">/lib/ld-linux.so.2 (0x006a8000)</span><br><span class="line">libdl.so.2 =&gt; /lib/libdl.so.2 (0x008c3000)</span><br><span class="line">可以看出 libpcre.so.1 =&gt; not found 并没有找到，进入/lib目录中手动链接下</span><br><span class="line"># ln -s libpcre.so.0.0.1 libpcre.so.1</span><br></pre></td></tr></table></figure>

<p>然后在启动nginx ok 了</p>
<pre><code>注意：要确定系统的80端口是否被占用，如果被占用，可用vi命令修改nginx.conf，具体修改方法见下面的配置文件。
检查是否启动成功：ps -ef | grep nginx。
如果成功了，看看在浏览器中输入http://127.0.0.1 是否访问到了Nginx欢迎界面？访问到就恭喜你安装成功了！</code></pre><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br></pre></td><td class="code"><pre><span class="line">1.	user  root;  </span><br><span class="line">2.	worker_processes  1;  </span><br><span class="line">3.	worker_rlimit_nofile 65535;  </span><br><span class="line">4.	  </span><br><span class="line">5.	#error_log  logs/error.log;  </span><br><span class="line">6.	#error_log  logs/error.log  notice;  </span><br><span class="line">7.	#error_log  logs/error.log  info;  </span><br><span class="line">8.	  </span><br><span class="line">9.	#pid        logs/nginx.pid;  </span><br><span class="line">10.	  </span><br><span class="line">11.	  </span><br><span class="line">12.	events &#123;  </span><br><span class="line">13.	    worker_connections  12040;  </span><br><span class="line">14.	&#125;  </span><br><span class="line">15.	  </span><br><span class="line">16.	  </span><br><span class="line">17.	http &#123;  </span><br><span class="line">18.	    include       mime.types;  </span><br><span class="line">19.	    default_type  application/octet-stream;  </span><br><span class="line">20.	    #Proxy_cache_path    /usr/local/nginx/NginxTestImgLog levels=1:2  keys_zone=cache_one:200m inactive=1d max_size=30g;  </span><br><span class="line">21.	  </span><br><span class="line">22.	    #log_format  main  &apos;$remote_addr - $remote_user [$time_local] &quot;$request&quot; &apos;  </span><br><span class="line">23.	    #                  &apos;$status $body_bytes_sent &quot;$http_referer&quot; &apos;  </span><br><span class="line">24.	    #                  &apos;&quot;$http_user_agent&quot; &quot;$http_x_forwarded_for&quot;&apos;;  </span><br><span class="line">25.	  </span><br><span class="line">26.	    #access_log  logs/access.log  main;  </span><br><span class="line">27.	  </span><br><span class="line">28.	    sendfile        on;  </span><br><span class="line">29.	    #tcp_nopush     on;  </span><br><span class="line">30.	  </span><br><span class="line">31.	    #keepalive_timeout  0;  </span><br><span class="line">32.	    keepalive_timeout  65;  </span><br><span class="line">33.	  </span><br><span class="line">34.	    #gzip  on;  </span><br><span class="line">35.	  </span><br><span class="line">36.	    server &#123;  </span><br><span class="line">37.	        listen       8088;  </span><br><span class="line">38.	        server_name  localhost;  </span><br><span class="line">39.	  </span><br><span class="line">40.	        #charset koi8-r;  </span><br><span class="line">41.	  </span><br><span class="line">42.	        #access_log  logs/host.access.log  main;  </span><br><span class="line">43.	  </span><br><span class="line">44.	       location / &#123;</span><br><span class="line">45.	            root   /home/hadoop/;</span><br><span class="line">46.	            autoindex on;</span><br><span class="line">47.	            autoindex_exact_size off;</span><br><span class="line">48.	            autoindex_localtime on;</span><br><span class="line">49.	            index  index.html index.htm;</span><br><span class="line">50.	        &#125;</span><br><span class="line">51.	  </span><br><span class="line">52.	        #error_page  404              /404.html;  </span><br><span class="line">53.	  </span><br><span class="line">54.	        # redirect server error pages to the static page /50x.html  </span><br><span class="line">55.	        #  </span><br><span class="line">56.	        error_page   500 502 503 504  /50x.html;  </span><br><span class="line">57.	        location = /50x.html &#123;  </span><br><span class="line">58.	            root   html;  </span><br><span class="line">59.	        &#125;  </span><br><span class="line">60.	  </span><br><span class="line">61.	        # proxy the PHP scripts to Apache listening on 127.0.0.1:80  </span><br><span class="line">62.	        #  </span><br><span class="line">63.	        #location ~ \.php$ &#123;  </span><br><span class="line">64.	        #    proxy_pass   http://127.0.0.1;  </span><br><span class="line">65.	        #&#125;  </span><br><span class="line">66.	  </span><br><span class="line">67.	        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000  </span><br><span class="line">68.	        #  </span><br><span class="line">69.	        #location ~ \.php$ &#123;  </span><br><span class="line">70.	        #    root           html;  </span><br><span class="line">71.	        #    fastcgi_pass   127.0.0.1:9000;  </span><br><span class="line">72.	        #    fastcgi_index  index.php;  </span><br><span class="line">73.	        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;  </span><br><span class="line">74.	        #    include        fastcgi_params;  </span><br><span class="line">75.	        #&#125;  </span><br><span class="line">76.	  </span><br><span class="line">77.	        # deny access to .htaccess files, if Apache&apos;s document root  </span><br><span class="line">78.	        # concurs with nginx&apos;s one  </span><br><span class="line">79.	        #  </span><br><span class="line">80.	        #location ~ /\.ht &#123;  </span><br><span class="line">81.	        #    deny  all;  </span><br><span class="line">82.	        #&#125;  </span><br><span class="line">83.	    &#125;  </span><br><span class="line">84.	  </span><br><span class="line">85.	  </span><br><span class="line">86.	    # another virtual host using mix of IP-, name-, and port-based configuration  </span><br><span class="line">87.	    #  </span><br><span class="line">88.	    #server &#123;  </span><br><span class="line">89.	    #    listen       8000;  </span><br><span class="line">90.	    #    listen       somename:8080;  </span><br><span class="line">91.	    #    server_name  somename  alias  another.alias;  </span><br><span class="line">92.	  </span><br><span class="line">93.	    #    location / &#123;  </span><br><span class="line">94.	    #        root   html;  </span><br><span class="line">95.	    #        index  index.html index.htm;  </span><br><span class="line">96.	    #    &#125;  </span><br><span class="line">97.	    #&#125;  </span><br><span class="line">98.	  </span><br><span class="line">99.	  </span><br><span class="line">100.	    # HTTPS server  </span><br><span class="line">101.	    #  </span><br><span class="line">102.	server &#123;  </span><br><span class="line">103.	        listen       7788;  </span><br><span class="line">104.	        server_name  localhost;  </span><br><span class="line">105.	    #    ssl on;  </span><br><span class="line">106.	    #    ssl_certificate      /usr/local/nginx/conf/server.crt;  </span><br><span class="line">107.	    #    ssl_certificate_key  /usr/local/nginx/conf/server_nopwd.key;  </span><br><span class="line">108.	  </span><br><span class="line">109.	    charset utf-8;  </span><br><span class="line">110.	    #charset koi8-r;  </span><br><span class="line">111.	      </span><br><span class="line">112.	    location ~ (\.jsp)|(\.do)/ &#123;  </span><br><span class="line">113.	        proxy_pass http://127.0.0.1:7001;  </span><br><span class="line">114.	        proxy_set_header X-Real-IP $remote_addr;  </span><br><span class="line">115.	          </span><br><span class="line">116.	        proxy_set_header Host $host;  </span><br><span class="line">117.	        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;  </span><br><span class="line">118.	        proxy_buffer_size 4k;  </span><br><span class="line">119.	        proxy_buffers 4 32k;  </span><br><span class="line">120.	        proxy_busy_buffers_size 64k;  </span><br><span class="line">121.	        proxy_temp_file_write_size 64k;  </span><br><span class="line">122.	        proxy_max_temp_file_size 512m;  </span><br><span class="line">123.	      &#125;  </span><br><span class="line">124.	    &#125;  </span><br><span class="line">125.	      </span><br><span class="line">126.	    server &#123;  </span><br><span class="line">127.	            listen 8888;  </span><br><span class="line">128.	            server_name localhost;  </span><br><span class="line">129.	          </span><br><span class="line">130.	        charset utf-8;  </span><br><span class="line">131.	          </span><br><span class="line">132.	            location ~ .*\.(gif|jpg|jpeg|png)&#123;  </span><br><span class="line">133.	                #allow 127.0.0.1;  </span><br><span class="line">134.	                #deny all;  </span><br><span class="line">135.	                  </span><br><span class="line">136.	                #expires 24h;  </span><br><span class="line">137.	                    root /usr/local/nginx/nginxTestImg/;  </span><br><span class="line">138.	                    access_log /usr/local/nginx/NginxTestImgLog/log_test.log;  </span><br><span class="line">139.	                    proxy_store on;  </span><br><span class="line">140.	                    proxy_store_access user:rw group:rw all:rw;  </span><br><span class="line">141.	                      </span><br><span class="line">142.	                    proxy_redirect    off;  </span><br><span class="line">143.	                      </span><br><span class="line">144.	                    proxy_set_header  Host $host;  </span><br><span class="line">145.	                    proxy_set_header  X-Real-IP $remote_addr;  </span><br><span class="line">146.	                    proxy_set_header  X-Forwarded-For $remote_addr;  </span><br><span class="line">147.	                    client_max_body_size       10m;  </span><br><span class="line">148.	                    client_body_buffer_size    1280k;  </span><br><span class="line">149.	                    proxy_connect_timeout      900;  </span><br><span class="line">150.	                    proxy_send_timeout         900;  </span><br><span class="line">151.	                    proxy_read_timeout         900;  </span><br><span class="line">152.	                    proxy_buffer_size          1024k;  </span><br><span class="line">153.	                    proxy_buffers              40 1024k;  </span><br><span class="line">154.	                    proxy_busy_buffers_size    1024k;  </span><br><span class="line">155.	                    proxy_temp_file_write_size 1024k;  </span><br><span class="line">156.	                proxy_temp_path    /usr/local/nginx/nginxTestImg/;  </span><br><span class="line">157.	                #Proxy_cache_path /nginxTestImg/;  </span><br><span class="line">158.	                if ( !-e $request_filename)  </span><br><span class="line">159.	                    &#123;  </span><br><span class="line">160.	                proxy_pass http://127.0.0.1:8888;  </span><br><span class="line">161.	                    &#125;  </span><br><span class="line">162.	                      </span><br><span class="line">163.	            &#125;  </span><br><span class="line">164.	            location / &#123;  </span><br><span class="line">165.	                root html;  </span><br><span class="line">166.	                index index.html index.htm;  </span><br><span class="line">167.	            &#125;  </span><br><span class="line">168.	              </span><br><span class="line">169.	            #error_page 404   /404.html;  </span><br><span class="line">170.	            # redirect server error pages to the static page /50x.html  </span><br><span class="line">171.	            #  </span><br><span class="line">172.	            error_page   500 502 503 504  /50x.html;  </span><br><span class="line">173.	            location = /50x.html &#123;  </span><br><span class="line">174.	                root   html;  </span><br><span class="line">175.	            &#125;  </span><br><span class="line">176.	              </span><br><span class="line">177.	          </span><br><span class="line">178.	    &#125;  </span><br><span class="line">179.	  </span><br><span class="line">180.	&#125;</span><br></pre></td></tr></table></figure>

<p>配置完后，执行reload命令重新加载配置文件。然后放入一张图片（如，cat.jpg）后进行访问<a href="http://127.0.0.1:8888/cat.jpg" target="_blank" rel="noopener">http://127.0.0.1:8888/cat.jpg</a> ，如果能访问，说明搭建成功。</p>
<h4 id="2-搭建FTP服务器"><a href="#2-搭建FTP服务器" class="headerlink" title="2. 搭建FTP服务器"></a>2. 搭建FTP服务器</h4><ol>
<li>安装，使用yum命令在Linux上安装即可</li>
<li>启动ftp服务 cd /ect/vsftpd（ftp的安装目录）   换行，./vsftpd.conf 或者service vsftpd restart(通用)systemctl restart  vsftpd.service</li>
<li>之后比较关键的是修改配置文件：</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">首先，新建一个用户，如apple，并为其设置密码</span><br><span class="line"># useradd -d /etc/vsftpd/apple -g ftp -s /sbin/nologin apple //增加用户apple，并制定test用户的主目录为/etc/vsftpd/apple  </span><br><span class="line"># passwd apple//为test设置密码  </span><br><span class="line">然后，把apple加到/etc/vsftpd/user_list文件中；如果该文件的同级文件vsftpd.chroot_list和ftpusers中含有你注册的用户名，要将其在这两个文件中注掉。</span><br><span class="line">重启ftp服务，命令见（2），就OK啦。</span><br><span class="line">还有一点要注意的是，如果使用ftp过程总是说无权限，要看看是否你的vsftpd里的文件有读写权限，设置属性即可。</span><br><span class="line">chkconfig 服务名 on</span><br></pre></td></tr></table></figure>


  </article>
  <aside class="table-content" id="site-toc">
  <div class="table-content-title">
    <i class="fa fa-arrow-right fa-lg" id="site-toc-hide-btn"></i>
    <span>目录</span>
  </div>
  <div class="table-content-main">
    <ol class="toc"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-搭建nginx"><span class="toc-text">1.搭建nginx</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-搭建FTP服务器"><span class="toc-text">2. 搭建FTP服务器</span></a></li></ol>
  </div>
</aside>
  
  
    <div class="passage-tags">
     
      <a href="/blog/tags/linux/"><i class="fa fa-tags"></i>linux</a>
     
      <a href="/blog/tags/nginx/"><i class="fa fa-tags"></i>nginx</a>
     
      <a href="/blog/tags/ftp/"><i class="fa fa-tags"></i>ftp</a>
    
    </div>
  
</div>

    </main>
    
      
<div class="site-comment-contanier" data-plateform="leancloud">
  
    <p id="site-comment-info">
      <i class="fa fa-spinner fa-spin"></i> 评论加载中
    </p>
    <div id="site-comment"></div>
  
</div>
    
    <div class="site-footer-wrapper">
  <footer class="site-footer">
    
      
        <div class="site-footer-col">
          <h5 class="site-footer-title">博客推荐</h5>
          
            <span class="site-footer-item">
              <a href="https://gitee.com/youxiaxiaomage/" target="_blank">youxiaxiaomage</a>
            </span>
          
        </div>
      
    
    <div class="site-footer-info">
      <i class="fa fa-clock-o"></i> 本站已稳定运行<span id="site-time"></span>
    </div>
    
    
      <div class="site-footer-info">
        <i class="fa fa-at"></i> Email: yanzhao_jn@163.com
      </div>
    
    <div class="site-footer-info">
      <i class="fa fa-copyright"></i> 
      2019 <a href="https://gitee.com/youxiaxiaomage/" target="_blank">youxiaxiaomage</a>.
      Created by <a href="https://gitee.com/youxiaxiaomage/" target="_blank">游侠小马哥</a>.
      All rights reserved.
    </div>
  </footer>
</div>
    <div id="site-layer" style="display:none;">
  <div class="site-layer-content">
    <div class="site-layer-header">
      <span class="site-layer-header-title" id="site-layer-title"></span>
      <i class="fa fa-close" id="site-layer-close"></i>
    </div>
    <div class="site-layer-body" id="site-layer-container">
      <div class="site-layer-input" id="site-layer-search" style="display: none;">
        <div class="site-layer-input-choose">
          <a href="javascript:void(0);" title="Change Search Engine">Google</a>
        </div>
        <input type="text">
        <i class="fa fa-search"></i>
      </div>
      
        <div class="site-layer-reward" id="site-layer-reward" style="display: none;">
          
            <div>
              <img src="/blog/images/wechat.png" alt="WeChat">
              
                <p>WeChat</p>
              
            </div>
          
            <div>
              <img src="/blog/images/alipay.png" alt="AliPay">
              
                <p>AliPay</p>
              
            </div>
          
        </div>
      
      <div id="site-layer-welcome" style="display:none;"></div>
    </div>
  </div>
</div>
    

<div class="bottom-bar">
  <div class="bottom-bar-left">
    <a href="/blog/passages/IDEA下tomcat8源码编译/" data-enable="true">
      <i class="fa fa-arrow-left"></i>
    </a>
    <a href="/blog/passages/mariadb/" data-enable="true">
      <i class="fa fa-arrow-right"></i>
    </a>
  </div>
  <div class="bottom-bar-right">
    <a href="javascript:void(0);" data-enable="true" id="site-toc-show-btn">
      <i class="fa fa-bars"></i>
    </a>
    
      <a href="#site-comment" data-enable="true">
        <i class="fa fa-commenting"></i>
      </a>
    
    <a href="javascript:void(0);" id="site-toggle-share-btn">
      <i class="fa fa-share-alt"></i>
    </a>
    
      <a href="javascript:void(0);" id="site-reward">
        <i class="fa fa-thumbs-up"></i>
      </a>
    
    <a href="javascript:void(0);" id="back-top-btn">
      <i class="fa fa-chevron-up"></i>
    </a>
  </div>
</div>
    <div id="share-btn">
  
  
  
    <a id="share-btn-weibo" href="javascript:void(0);" target="_blank">
      <i class="fa fa-weibo"></i>
    </a>
  
  
    <a id="share-btn-qq" href="javascript:void(0);" target="_blank">
      <i class="fa fa-qq"></i>
    </a>
  
  
    <a id="share-btn-wechat" href="javascript:void(0);" target="_blank">
      <i class="fa fa-wechat"></i>
    </a>
  
</div>
    





    
  </body>
</html>